// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   check_delete_ok.java

package hr.training;

import include.nseer_cookie.exchange;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class check_delete_ok extends HttpServlet
{

	ServletContext application;
	HttpSession session;

	public check_delete_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			java.io.PrintWriter out = response.getWriter();
			nseer_db_backup1 hr_db = new nseer_db_backup1(dbApplication);
			nseer_db_backup1 hr_db1 = new nseer_db_backup1(dbApplication);
			if (hr_db.conn((String)dbSession.getAttribute("unit_db_name")) && hr_db1.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String config_id = request.getParameter("config_id");
				String training_time = request.getParameter("training_time");
				String choice = request.getParameter("choice");
				String human_ID = request.getParameter("human_ID");
				String checker = request.getParameter("checker");
				String check_time = request.getParameter("check_time");
				String bodyb = new String(request.getParameter("remark").getBytes("UTF-8"), "UTF-8");
				String remark = exchange.toHtml(bodyb);
				String sql6 = (new StringBuilder("select id from hr_workflow where object_ID='")).append(human_ID).append("' and training_time='").append(training_time).append("' and type_id='05' and ((check_tag='0' and config_id<'").append(config_id).append("') or (check_tag='1' and config_id='").append(config_id).append("'))").toString();
				ResultSet rs6 = hr_db.executeQuery(sql6);
				if (!rs6.next())
				{
					String sql8 = (new StringBuilder("select * from hr_training where human_ID='")).append(human_ID).append("' and check_tag='0'").toString();
					ResultSet rs8 = hr_db.executeQuery(sql8);
					if (rs8.next())
						try
						{
							if (choice != null)
							{
								if (choice.equals(""))
								{
									String sql = (new StringBuilder("update hr_training set remark='")).append(remark).append("',checker='").append(checker).append("',check_time='").append(check_time).append("',check_tag='9' where human_ID='").append(human_ID).append("' and training_time='").append(training_time).append("' and check_tag='0'").toString();
									hr_db.executeUpdate(sql);
									sql = (new StringBuilder("delete from hr_workflow where object_ID='")).append(human_ID).append("' and training_time='").append(training_time).append("' and type_id='05'").toString();
									hr_db.executeUpdate(sql);
								} else
								{
									sql6 = (new StringBuilder("select id from hr_workflow where object_ID='")).append(human_ID).append("' and training_time='").append(training_time).append("' and type_id='05' and config_id<'").append(config_id).append("' and config_id>='").append(choice).append("'").toString();
									String sql;
									for (rs6 = hr_db.executeQuery(sql6); rs6.next(); hr_db1.executeUpdate(sql))
										sql = (new StringBuilder("update hr_workflow set check_tag='0' where id='")).append(rs6.getString("id")).append("' and type_id='05'").toString();

								}
								response.sendRedirect("hr/training/check_delete_ok.jsp?finished_tag=0");
							} else
							{
								response.sendRedirect("hr/training/check_delete_ok.jsp?finished_tag=1");
							}
						}
						catch (Exception ex)
						{
							ex.printStackTrace();
						}
					else
						response.sendRedirect("hr/training/check_delete_ok_a.jsp");
				} else
				{
					response.sendRedirect("hr/training/check_delete_ok.jsp?finished_tag=2");
				}
				hr_db.commit();
				hr_db.close();
				hr_db1.commit();
				hr_db1.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
